﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Dummy
{
    public partial class InviteWindow : ChildWindow
    {
        public string gamer { 
            get 
            { 
                if (lb_gamersList.SelectedIndex >= 0)
                    return lb_gamersList.SelectedItem.ToString();
                return null;
            }
        }

        public delegate void EventInvite(string gamerName);
        public event EventInvite onSendInvite;
        //public event EventInvite onRecieveInvite;

        public InviteWindow()
        {
            InitializeComponent();
            tbl_message.Text = "";
            tbl_error.Text = "";
        }

        public void ShowMessage(string message)
        {
            tbl_message.Text = message;
        }

        public void ShowError(string error)
        {
            tbl_error.Text = error;
        }

        public void ProcessingSendInvite(bool process)
        {
            if (process)
            {
                lb_gamersList.IsEnabled = false;
                bt_invite.IsEnabled = false;
            }
            else
            {
                lb_gamersList.IsEnabled = true;
                bt_invite.IsEnabled = true;
            }
        }

        private void bt_invite_click(object sender, RoutedEventArgs e)
        {
            //this.DialogResult = true;
            InvokeSendInvite();
        }

        public void Init(string[] gamerList)
        {
            lb_gamersList.Items.Clear();
            foreach (string gamerName in gamerList)
                lb_gamersList.Items.Add(gamerName);
        }

        public void AddGamerToList(string newGamerName)
        {
            lb_gamersList.Items.Add(newGamerName);
        }

        private void InvokeSendInvite()
        {
            if (onSendInvite != null)
                onSendInvite(gamer);
        }
    }
}

